package com.bocom.controller;

import com.bocom.service.InterfaceAPIService;
import com.bocom.vo.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Author shenzhifeng
 * Create time  2019/8/26 11:16
 * Description
 * Modifier
 * Reasons
 */
@Slf4j
@RestController
@RequestMapping("/online")
public class InterfaceAPIController {

    private int count = 0;

    private int countphoto = 0;

    private int count3 = 0;

    @Resource
    private InterfaceAPIService interfaceAPIService;


    @PostMapping("/Bus_SiteInfo")
    public ApiResponseVO Bus_SiteInfo(@RequestBody BusSiteInfo busSiteInfo){
        try {
            log.info("Bus_SiteInfo---->>>：{}",busSiteInfo);
            interfaceAPIService.insertBusSiteInfo(busSiteInfo);
            return ApiResponseVO.ofSuccess();
        }catch (Exception e){
            log.error(e.toString());
            return ApiResponseVO.ofError();
        }
    }


    @PostMapping("/Bus_Info")
    public ApiResponseVO Bus_Info(@RequestBody BusInfo busInfo){
        try {
            log.info("Bus_Info---->>>：{}",busInfo);
            interfaceAPIService.insertBusInfo(busInfo);
            return ApiResponseVO.ofSuccess();
        }catch (Exception e){
            log.error(e.toString());
            return ApiResponseVO.ofError();
        }
    }


    @PostMapping("/Bus_PersonInfo")
    public ApiResponseVO Bus_PersonInfo(@RequestBody BusPersonInfo busPersonInfo){
        try {
            log.info("Bus_PersonInfo---->>>：{}",busPersonInfo);
            interfaceAPIService.insertBusPersonInfo(busPersonInfo);
            return ApiResponseVO.ofSuccess();
        }catch (Exception e){
            log.error(e.toString());
            return ApiResponseVO.ofError();
        }
    }

    @PostMapping("/Bus_Frequency")
    public ApiResponseVO Bus_Frequency(@RequestBody BusFrequency busFrequency){
        try {
            log.info("Bus_Frequency---->>>：{}",busFrequency);
            interfaceAPIService.insertBusFrequency(busFrequency);
            return ApiResponseVO.ofSuccess();
        }catch (Exception e){
            log.error(e.toString());
            return ApiResponseVO.ofError();
        }
    }

    @PostMapping("/Bus_Gps")
    public ApiResponseVO Bus_Gps(@RequestBody BusGps busGps){
        try {
            log.info("Bus_Gps---->>>：{}",busGps);
            interfaceAPIService.insertBusGps(busGps);
            return ApiResponseVO.ofSuccess();
        }catch (Exception e){
            log.error(e.toString());
            return ApiResponseVO.ofError();
        }
    }



    @PostMapping("/Bus_Pic")
    public ApiResponseVO Bus_Pic(@RequestBody BusPic busPic){
        try {
            log.info("Bus_Pic---->>>：{}",busPic);
            interfaceAPIService.insertBusPic(busPic);
            return ApiResponseVO.ofSuccess();
        }catch (Exception e){
            log.error(e.toString());
            return ApiResponseVO.ofError();
        }
    }




}
